//package com.zy.oauth.shiro;
//
//import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
//import org.apache.shiro.authc.pam.AtLeastOneSuccessfulStrategy;
//import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
//import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import static org.springframework.messaging.simp.stomp.StompHeaders.LOGIN;
//import static org.springframework.security.config.Elements.JWT;
//
//@Configuration
//public class ShiroConfig {
//
//    /*
//     * 解决spring aop和注解配置一起使用的bug。如果您在使用shiro注解配置的同时，引入了spring
//     * aop的starter，会有一个奇怪的问题，导致shiro注解的请求，不能被映射
//     */
//    @Bean
//    public static DefaultAdvisorAutoProxyCreator creator() {
//        DefaultAdvisorAutoProxyCreator creator = new DefaultAdvisorAutoProxyCreator();
//        creator.setProxyTargetClass(true);
//        return creator;
//    }
//
//    @Bean
//    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
//        AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
//        authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
//        return authorizationAttributeSourceAdvisor;
//    }
//    @Bean("hashedCredentialsMatcher")
//    public HashedCredentialsMatcher hashedCredentialsMatcher() {
//        HashedCredentialsMatcher matcher = new HashedCredentialsMatcher();
//        matcher.setHashAlgorithmName("SHA-256");
//        matcher.setStoredCredentialsHexEncoded(true);
//        return matcher;
//    }
//
//    @Bean
//    public LoginRealm loginRealm(@Qualifier("hashedCredentialsMatcher") HashedCredentialsMatcher matcher) {
//        LoginRealm loginRealm = new LoginRealm(LOGIN);
//        loginRealm.setCredentialsMatcher(matcher);
//        return loginRealm;
//    }
//
//    @Bean
//    public JwtRealm jwtRealm() {
//        return new JwtRealm(JWT);
//    }
//
//    @Bean
//    public OurModularRealmAuthenticator userModularRealmAuthenticator() {
//        // rewrite ModularRealmAuthenticator
//        DataAuthModularRealmAuthenticator modularRealmAuthenticator = new DataAuthModularRealmAuthenticator();
//        modularRealmAuthenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy());
//        return modularRealmAuthenticator;
//    }
//
//
//}
